<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03JS数据类型</title>
</head>
<body>
<script>
    //数据类型
    // 1.原始数据类型 number string boolean null undefined
    //2.引用数据类型：object array function date...
    var a=1;
    var b=9.9;
    var c='hello';
    var d="world";
    var e=true;
    var f;
    console.log(a,typeof a,b,typeof b,c,typeof c,d,typeof d,e,typeof e,f,typeof f);

    let x={};
    x.name='杨硕';
    x.age=18;
    console.log(x,typeof x);//{name:'杨硕',age:18} 'object'

    let y={
        name:'杨硕',
        age:18
    }
    console.log(y,typeof y);//{name:'杨硕',age:18} 'object'
    //数组
    let arr=['杨硕',18,true,5.5];//任意类型的都可以放在同一个数组中
    console.log(arr,typeof arr);
    console.log(arr[0],arr[1],arr[2],arr[3]);
    console.log(arr[999]);//undefined  超出数组范围的值，默认是undefined

    //转换为数值类型
    console.log(Number(true),typeof Number(true))//布尔型 转为数值类型
    console.log(Number(3))//数值型 转为数值类型
    console.log(Number('3'));//字符型 转为数值类型
    console.log(Number('杨硕爱吃糖'));//不是数值型 转为NaN
    //转换为布尔型
    console.log(Boolean(1),typeof Boolean(1))//数值类型 转为布尔类型 是true
    //0 null NaN  undefined  ''  转为布尔都是false
    console.log(Boolean(0));
    console.log(Boolean(null));
    console.log(Boolean(NaN));
    console.log(Boolean(undefined));
    console.log(Boolean(''));

    console.log(Boolean(' '));//true
    console.log(Boolean('杨硕'));//true

    //

</script>
</body>
</html>